
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Max
 */
public class VO extends Course implements FinalExamsInterface {
	private FinalExams finalExams;

	public VO(String lvanr, String title, double ects, double workinghours, GregorianCalendar enrollStart, GregorianCalendar enrollEnd, GregorianCalendar checkOutEnd, Professor professor) {
		super(lvanr, title, ects, workinghours, enrollStart, enrollEnd, checkOutEnd, professor);
		this.finalExams = new FinalExams();
	}

	public VO(String lvanr, String title, double ects, double workinghours, GregorianCalendar enrollStart, GregorianCalendar enrollEnd, GregorianCalendar checkOutEnd, Professor professor, boolean visible) {
		super(lvanr, title, ects, workinghours, enrollStart, enrollEnd, checkOutEnd, professor, visible);
		this.finalExams = new FinalExams();
	}
	
	@Override
	public FinalExams getFinalExams() {
		return finalExams;
	}

	@Override
	public void giveCertificate(Student student) {
		HashMap<GregorianCalendar, FinalExam> studentExams = finalExams.getGraduates().get(student);
		GregorianCalendar lastDate = new GregorianCalendar(1970, 1-1, 1);
		Iterator it = studentExams.keySet().iterator();
		while(it.hasNext()) {
			GregorianCalendar key = (GregorianCalendar)it.next();
			if(key.after(lastDate)) {
				lastDate = key;
			}
		}
		student.addCertificate(new Certificates(this, studentExams.get(lastDate).getMark(), this.getProfessor()));
	}
}